var layDate = angular.module('myApp');

/*laydate日期指令*/
layDate.directive("layDate",['UiUtilService',function (UiUtilService) {
    return {
        require:"ngModel",
        /*操作DOM*/
        link: function(scope, element, attrs,ctr) {
            laydate.render({
                elem: '#'+attrs.layDate, //指定元素
                done: function(value, date, endDate){ //监听日期被切换
                    // element.val(value);  //未起作用
                    ctr.$setViewValue(value);
                }
            });
        }
    };
}]);

/**
 * 年月选择器
 */
layDate.directive("layYearMonth",['UiUtilService',function (UiUtilService) {
    return {
        require:"ngModel",
        /*操作DOM*/
        link: function(scope, element, attrs,ctr) {
            laydate.render({
                elem: '#'+attrs.layYearMonth, //指定元素
                type: 'month', //年月
                done: function(value, date, endDate){ //监听日期被切换
                    // element.val(value);  //未起作用
                    console.log(attrs.layYearMonth);
                    console.log(value);
                    ctr.$setViewValue(value);
                }
            });
        }
    };
}]);